import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)


const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}

const router = new Router({
  routes: [
    {
      path: '/',
      component: () => import('../views/login')
    },
    {
      path: '/admin',
      component: () => import('../views/admin'),
      redirect: 'admin/article',
      children: [
        // --------------新闻管理
        {
          path: 'article',
          meta: { title: '新闻列表' },
          component: () => import('../views/sroom/sroom-article.vue')
        },
        // --------------sec文件管理
        {
          path: 'secfile',
          meta: { title: 'sec文件' },
          component: () => import('../views/pages/secfile.vue')
        },
        // --------------系统管理
        {
          path: 'set',
          meta: { title: '系统设置' },
          component: () => import('../views/pages/set.vue')
        },
        {
          path: 'relation',
          meta: { title: '联系我们' },
          component: () => import('../views/pages/relation.vue')
        },
        {
          path: 'consult',
          meta: { title: '管理员信息' },
          component: () => import('../views/pages/manager.vue')
        },
      ]
    }
  ]
})

export default router
